#ifndef HEADERDELEGATE_H
#define HEADERDELEGATE_H

#include <QWidget>

class MatrixBase;
class HeaderDelegatePrivate;
class HeaderDelegate : public QWidget
{
    Q_OBJECT
public:
    explicit HeaderDelegate(Qt::Orientation ori, QWidget *parent = 0);
    ~HeaderDelegate();

    void setIndex(int index);
    int index() const;

    void setMatrix(MatrixBase* matrix);
    Qt::Orientation orientation() const;

    QSize sizeHint() const;
    QSize minimumSizeHint() const;

signals:
    void clicked(const QPoint& pos);

protected:
    void resizeEvent(QResizeEvent *);
    void mousePressEvent(QMouseEvent* );
    void mouseMoveEvent(QMouseEvent *);

private slots:
    void onMatrixValueChanged(int row, int col, const QVariant& oldVal, const QVariant& newVal);
    void updateThumbnail();
    void onThumbnailPainterFinished();

private:
    template <class MatrixType>
    void fireupPainterThread();

private:
    HeaderDelegatePrivate* d_ptr;
    Q_DISABLE_COPY(HeaderDelegate)
};

#endif // HEADERDELEGATE_H
